package com.bmt.pos.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.bmt.core.BaseContoller;
import com.bmt.core.ISaveable;
import com.bmt.core.PageListInfo;
import com.bmt.exception.ServiceException;
import com.bmt.pos.service.UserModuleService;

@Controller
@RequestMapping(value = "modulemgr")
public class ModuleContoller extends BaseContoller {
	
	@Autowired
	private UserModuleService userModuleService;
	
	@RequestMapping(value = "modulerList.htm", method = RequestMethod.GET)
	public ModelAndView list() throws ServiceException {
		return new ModelAndView("redirect:page/1.htm");
	}

	@RequestMapping(value = "page/{pageNum}.htm", method = RequestMethod.GET)
	public ModelAndView getPage(@PathVariable Integer pageNum) throws Exception {
		ModelAndView mav = new ModelAndView("module_list");
		PageListInfo<ISaveable> plInfo = userModuleService.getPageInfo(pageNum);
		mav.addObject("plInfo", plInfo);
		return mav;
	}
}
